import request from '@/utils/request'

export function login(data) {
  // return new Promise((resolve) => {
  //   resolve({
  //     code: 200,
  //     data: {
  //       token: 'dfasfiok',
  //       user: { role: 2,username: '阿牛但是' }
  //     }
  //   })
  // })
  return request({
    url: 'admin/login',
    method: 'post',
    data
  })
}
// 修改密码
export function updateUser(data) {
  return request({
    url: '/admin/update-password',
    method: 'post',
    data
  })
}

// 修改密钥配置开关
export function updateSetting(data) {
  return request({
    url: '/setting-config',
    method: 'post',
    data
  })
}

// 查询密钥配置开关
export function getConfig() {
  return request({
    url: '/select-config',
    method: 'get'
  })
}

// 添加、修改排行
export function addRanking(data) {
  return request({
    url: '/admin/add-ranking',
    method: 'post',
    data
  })
}

// 删除排行
export function deleteRanking(id) {
  return request({
    url: '/admin/delete-ranking',
    method: 'post',
    data: { id }
  })
}

// 查询排行
export function getRankingList(data) {
  return request({
    url: '/admin/ranking/page',
    method: 'post',
    data
  })
}

// 添加、修改比赛
export function addCompetition(data) {
  return request({
    url: '/competition/add',
    method: 'post',
    data
  })
}

// 删除比赛
export function deleteCompetition(id) {
  return request({
    url: '/competition/delete',
    method: 'post',
    data: { id }
  })
}

// 查询比赛
export function getCompetitionList(data) {
  return request({
    url: '/competition/list',
    method: 'post',
    data
  })
}

// 添加、修改场地
export function addPlace(data) {
  return request({
    url: '/field/add',
    method: 'post',
    data
  })
}

// 删除场地
export function deletePlace(id) {
  return request({
    url: '/field/delete',
    method: 'post',
    data: { id }
  })
}

// 查询场地
export function getPlaceList(data) {
  return request({
    url: '/field/list',
    method: 'post',
    data
  })
}

// 添加预约信息
export function addAppointment(data) {
  return request({
    url: '/userOrder/add',
    method: 'post',
    data
  })
}

// 修改预约信息状态
export function updateAppointment(data) {
  return request({
    url: '/userOrder/update',
    method: 'post',
    data
  })
}
// 添加预约信息下单
export function addAppointmentOrder(data) {
  return request({
    url: '/grow_payment',
    method: 'post',
    data
  })
}

// 查询预约信息
export function getAppointmentList(data) {
  return request({
    url: '/userOrder/select-list',
    method: 'post',
    data
  })
}

// 生成密钥
export function generateKeys(data) {
  return request({
    url: '/admin/generate',
    method: 'post',
    data
  })
}

// 删除场地
export function deleteKey(id) {
  return request({
    url: '/field/delete',
    method: 'post',
    data: { id }
  })
}

// 查询密钥
export function getKeys(data) {
  return request({
    url: '/admin/sdk/page',
    method: 'post',
    data
  })
}

// 查询密钥详情
export function getKey(data) {
  return request({
    url: '/admin/sdk/get',
    method: 'post',
    data
  })
}
